Learning Objectives

After completing this lesson, you’ll be able to:

Instructions

In this lesson, you will:

Resources

Exercise

Jennifer

Jennifer is mapping her city's monthly precipitation. She has been handed a dataset of cumulative rainfall totals, but she wants to map the individual figure for each month. She builds a workspace that reads the cumulative precipitation data and writes the monthly values to a new Excel file.

In this exercise, you will:

The precipitation data is cumulative and looks like this:

Month Precipitation
Jan 168
Feb 273
Mar 387
Apr 476
May 541
Jun 595
Jul 631
Aug 668
Sep 719
Oct 840
Nov 1029
Dec 1191

1) Create Workspace

This workspace uses an Excel reader for the source data and an Excel writer for the results.

Connected feature types

2) Add AttributeManager

To calculate each month's precipitation, you subtract the previous month's cumulative total from the current month's total. FME's adjacent feature attribute functionality lets each feature fetch the previous month's value.

Adding an AttributeManager

3) Enable Adjacent Feature Attributes

You enable adjacent feature attributes so each feature can reference the one processed before it. The first feature has no prior feature, so you also set a substitution value; because this calculation is numeric, 0 is a sensible default.

Configuring Adjacent Feature Attributes

4) Build the Precipitation Calculation

Now you build the expression that subtracts the previous feature's value from the current feature's value.

Open Arithmetic Editor

Constructing the attribute value

5) Save and Run Workspace

When you run the workspace, the results start out correct but quickly go wrong, which reveals a problem with overwriting the attribute you are calculating from.

6) Create a New Output Attribute

To fix the calculation, you write the result to a new attribute called MonthlyPrecipitation instead of overwriting Precipitation.

Renaming the destination attribute

Calculating the value

7) Re-Run Workspace

With the calculation writing to a new attribute, the monthly values should now be correct.

Results